#ifndef SRC_COMPONENTS_UTILS_INCLUDE_UTILS_SIGNALS_H_
#define SRC_COMPONENTS_UTILS_INCLUDE_UTILS_SIGNALS_H_

#ifdef __QNXNTO__
typedef void (*sighandler_t)(int);
#else
#include <signal.h>
#endif
#include <defines.h>
#include <event.h>
#include <string>
#include <json/json.h>

namespace utils {

class MessageQueue
{
public:
    MessageQueue();
    ~MessageQueue();
    Json::Value Execute(int mode,const std::string &script);
private:
    Json::Value  executeScript(int mode,const std::string &script);
    void doEvent();
    static void event_timeout(
            evutil_socket_t  fd,
            short event,void *arg);
    static void event_cb(
            evutil_socket_t fd,
            short event,void *arg);
private:
    struct event_base *m_ebase;
    std::string m_strscript;
    int m_mode;
    Json::Value m_jsonResult;
};

BOOL WaitTerminationSignals(
        sighandler_t sig_handler);
}

#endif  // SRC_COMPONENTS_UTILS_INCLUDE_UTILS_SIGNALS_H_
